const connect = require('connect');

connect()
  .use(function hello(req, res) {
    foo();
    res.setHeader('Conteny-Type', 'text/plain');
    res.end('hello world');
  })
  .use(errorHanlder())
  .listen(3000);

function errorHanlder() {
  return function (err, req, res, next) {
    switch (env) {
      case 'development':
        res.setHeader('Content-Type', 'application/json');
        res.end(JSON.stringify(err));
        break;
      default:
        res.end('Server error');
    }
  };
}
